package be.vdab.entities;

import be.vdab.dao.SausenDAO;

public class Galgje {
	private final SausenDAO sausenDAO = new SausenDAO();
	private final String teRadenSaus = sausenDAO.getRandomSausNaam().toLowerCase();
	private int foutePogingen = 0;
	private String teTonenSaus;
	
	public Galgje() {
		StringBuffer saus = new StringBuffer();
		for (int i = 0; i<teRadenSaus.length();i++) {
			saus.append(".");
		}
		teTonenSaus = saus.toString().toLowerCase();
	}
	
	public String getTeTonenSaus() {
		return teTonenSaus;
		
	}
	public String getTeRadenSaus() {
		return teRadenSaus;
	}
	public int getFoutePogingen() {
		return foutePogingen;
	}
	
	public void zoekLetter(String letter) {
		char[] teRadenArray = teRadenSaus.toCharArray();
		char[] teTonenArray = teTonenSaus.toCharArray();
		char let = letter.charAt(0);
		for (int i = 0;i<teRadenSaus.length();i++ ) {
			if (teRadenArray[i]==let) {
				teTonenArray[i]=let;
			}
		}
		if (teTonenSaus.equalsIgnoreCase(new String(teTonenArray))) {
			foutePogingen++;
		}
		teTonenSaus = new String(teTonenArray);
		
	}
	
}
